#include "MsgANrCond.h"

using namespace kc_sf;

// --------------------------------------------------------- //

MsgANrCond::MsgANrCond( Operator op, int attachment_nr )
: c_anr_operator( op ),
  c_anr( attachment_nr )
{
}

// --------------------------------------------------------- //

Logic::Symbol *MsgANrCond::clone() const
{
	return new MsgANrCond( *this );
}

// --------------------------------------------------------- //

bool MsgANrCond::eval( const Message &msg )
{
	return
		c_anr_operator == Eq ? msg.mAttachments.size() == (size_t)c_anr
		: c_anr_operator == Ge ? msg.mAttachments.size() >= (size_t)c_anr
		: c_anr_operator == Gt ? msg.mAttachments.size() > (size_t)c_anr
		: c_anr_operator == Le ? msg.mAttachments.size() <= (size_t)c_anr
		: c_anr_operator == Lt ? msg.mAttachments.size() < (size_t)c_anr
		: c_anr_operator == Ne ? msg.mAttachments.size() != (size_t)c_anr
		: msg.mAttachments.size() >= (size_t)c_anr;
}
